﻿using System;
using System.ComponentModel;
using GTasksPlus.Code;

namespace GTasksPlus.Model
{
    public class TaskListItem : INotifyPropertyChanged
    {
        public string id { get; set; }
        public string kind { get; set; }
        public string selfLink { get; set; }
        private string _title;
        public string title
        {
            set
            {
                _title = value;
                OnPropertyChanged("Tasks");
            }
            get { return _title; }
        }
        
        public event PropertyChangedEventHandler PropertyChanged;

        public TaskListItem(string title, string id, string kind,string selflink)
        {
            this.id = id;
            this.kind = kind;
            this.selfLink = selflink;
            _title = title;
        }

        public TaskListItem()
        {
            
        }

        public void Delete(Action<bool> Response)
        {
            TaskListHelper.DeleteList(this, Response);
            OnPropertyChanged("Tasks");
        }

        public void Update(Action<bool> Response)
        {
            TaskListHelper.UpdateList(this, Response);
            OnPropertyChanged("Tasks");
        }

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
